sizerequest: Optimize CONSTANT_SIZE better
authorBenjamin Otte <otte@redhat.com>
Wed, 14 Nov 2012 13:03:47 +0000 (14:03 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 14 Nov 2012 13:03:47 +0000 (14:03 +0100)
We can set for_size to -1 earlier than we did. Doing so makes sure we
only cache one value (as we should in the first place). In GTK 3.6, this
worked properly, but with Previously, this check was moved further up to
avoid interacting with size groups. But after recent refactorings, size
groups are handled way earlier anyway.

gtk/gtksizerequest.c

index 644b47a521613faec7e29423d811655e56f63a79..7ad94398bb4aa88dc5fde0db7da2b00bcfcf3d68 100644 (file)
@@ -105,6 +105,9 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
   gint nat_size = 0;
   gboolean found_in_cache;
 
+  if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
+    for_size = -1;
+
   cache = _gtk_widget_peek_request_cache (widget);
   found_in_cache = _gtk_size_request_cache_lookup (cache,
                                                    orientation,
@@ -120,7 +123,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
 
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
+          if (for_size < 0)
             {
              push_recursion_check (widget, orientation, for_size);
               GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_size, &nat_size);
@@ -153,7 +156,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
         }
       else
         {
-          if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
+          if (for_size < 0)
             {
              push_recursion_check (widget, orientation, for_size);
               GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_size, &nat_size);